﻿using DapperExtensions;
using Nova_Common.Extend;
using Nova_DAL;
using Nova_MOD;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Nova_BLL
{
    public class TBase_MaterialBll
    {
        private readonly TBase_MaterialDal dal = new TBase_MaterialDal();

        public List<TBase_Material> GetListByGroupType(int groupType)
        {
            var predicate = Predicates.Field<TBase_Material>(t => t.GroupType, Operator.Eq, groupType);
            return dal.GetList(predicate);
        }

        public TBase_Material GetByMatCode(string matCode)
        {
            var predicate = Predicates.Field<TBase_Material>(t => t.Mat_Code, Operator.Eq, matCode);
            return dal.GetByField(predicate);
        }

        public bool InsertEntity(TBase_Material entity)
        {
            return !dal.Insert(entity).IsEmpty();
        }

        public bool UpdateEntity(TBase_Material entity)
        {
            return dal.Update(entity);
        }
    }
}
